import java.util.Scanner;

public class Demo01 {
    public static void main(String[] args) throws InterruptedException {
        Object locker1 = new Object();
        Object locker2 = new Object();

        Thread t1 = new Thread(() -> {
            synchronized (locker1){
                System.out.println("线程1开始");
                try {
                    locker1.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("线程1结束");
                locker1.notify();
            }
        });

        Thread t2 = new Thread(() -> {
            synchronized (locker1){
                System.out.println("线程2开始");
                try {
                    locker1.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }

                System.out.println("线程2结束");
            }
        });

        Thread t3 = new Thread(() -> {
            synchronized (locker1){
                System.out.println("线程3开始");
                locker1.notify();
                System.out.println("线程3结束");
            }
        });

        t1.start();
        Thread.sleep(100);
        t2.start();
        Thread.sleep(100);
        t3.start();


    }
}
